import { ecsclass, EcsComponent } from "db://pkg/@gamex/cc-ecs";
import { MyEntity } from "../entity/MyEntity";
import { v3 } from "cc";

@ecsclass('AutoMoveComponent')
export class AutoMoveComponent extends EcsComponent<MyEntity> {
    static allowRecycling: boolean = true;

    protected onRemove() {
        this._speed = 1;
        this._distance = 0;
        this._maxDistance = 10; 
    }

    /** 速度 */
    private _speed = 1;
    public get speed() {
        return this._speed;
    }
    public set speed(value) {
        this._speed = value;
    }
    /** 移动距离 */
    private _distance = 0;
    public get distance() {
        return this._distance;
    }
    public set distance(value) {
        this._distance = value;
    }
    /** 最大移动距离 */
    private _maxDistance = 10;
    public get maxDistance() {
        return this._maxDistance;
    }
    public set maxDistance(value) {
        this._maxDistance = value; 
    }
    /** 移动方向 */
    private _toward = v3();
    public get toward() {
        return this._toward; 
    }
    public set toward(value) {
        this._toward = value; 
    }
}